
package com.erclab.internal.xpresso.unittests;

import junit.framework.TestCase;

import com.erclab.internal.xpresso.*;
import com.erclab.internal.xpresso.security.User;
import com.erclab.internal.xpresso.conf.Settings;
import com.erclab.internal.xpresso.dataAccess.ApplicationDataSource;
import com.erclab.internal.xpresso.dataAccess.GenericResultSet;
import com.erclab.internal.xpresso.exceptions.ApplicationException;
import com.erclab.internal.xpresso.exceptions.DataSourceException;
import com.erclab.internal.xpresso.exceptions.DirectoryException;

public class OracleAccessTest extends TestCase {

	Application xpresso = null;
	User user = null;

	/**
	 * Constructor for OracleAccessTest.
	 * @param arg0
	 */
	public OracleAccessTest(String arg0) {
		super(arg0);
	}


	protected void setUp() throws Exception {
		super.setUp();
		try {
			xpresso = new Application();
		} catch(ApplicationException e){
			fail("Create Application failed: " + e.toString());
		}
		try {
			user = new User();
			Settings.getUserDirectory().loadUserBean(user);
		} catch (DirectoryException e) {
			fail();
			e.printStackTrace();
		}
	}
	
	public void testConnection(){
		ApplicationDataSource ora = Settings.getRepository().getApplicationDataSource(3);
		
		try {
			GenericResultSet grs = ora.runQuery("SELECT COUNT(*) FROM PROJCOM.PROJINFO");
			grs.nextRow();
			System.out.println(grs.getRow()[0]);
		} catch (DataSourceException e) {
			e.printStackTrace();
			fail();
		}
	}

}
